package com.jiepos.mpos.biz.appInfM.controller;

import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.view.RedirectView;

import com.jiepos.mpos.biz.appInfM.service.HeadAdvService;
import com.jiepos.mpos.common.entity.App_Client_HeadadvEntity;
import com.jiepos.mpos.common.entity.App_Ins_AppEntity;
import com.jiepos.mpos.common.entity.App_Ins_InfEntity;
import com.jiepos.mpos.core.controller.BaseController;
import com.jiepos.mpos.core.entity.Pagination;
import com.jiepos.mpos.core.util.StringUtils;

/**
 *
 *
 * <p>标题: —— 系统参数控制器</p>
 * <p>模块: 通用平台</p>
 * <p>版权: Copyright (c) 2017 江苏杰博实信息技术有限公司
 * @author 余翼膑
 * @version 1.0
 * @since 2017年9月25日
 * @history（历次修订内容、修订人、修订时间等）
 */
@Controller
@RequestMapping("headAdv")
public class HeadAdvController extends BaseController {
    @Autowired
    private HeadAdvService headAdvService;

    /**
     * 进入参数信息列表页面
     * @param request
     * @param response
     * @param pagination
     * @param
     * @return
     */
    @RequestMapping("/getHeadAdvList.do")
    public ModelAndView getHeadAdvList(HttpServletRequest request, HttpServletResponse response,
                                    Pagination pagination) {
        ModelAndView model = new ModelAndView("/module/appInfM/headadv/headadv_list");
        return super.getDetail(request, response, model);
    }
  /**
     * 查询参数列表信息json数据
     * @param
     * @param
     * @param pagination
     * @param appClientEntity
     * @return
     */
    @RequestMapping("/getHeadAdvListJson.do")
    public @ResponseBody
    Map getHeadAdvListJson(HttpServletRequest request,Pagination pagination, App_Client_HeadadvEntity appClientEntity , App_Ins_AppEntity appInsAppEntity, App_Ins_InfEntity appInsInfEntity) {

        return headAdvService.getAppHeadAdv(request,pagination, appClientEntity,appInsAppEntity,appInsInfEntity);
    }
    /**
     * 进入广告位维护新增页面
     * @param request
     * @param response
     * @param pagination
     * @param adv_uuid
     * @return
     */
    @RequestMapping("/getHeadAdvDetail.do")
    public ModelAndView getHeadAdvDetail(HttpServletRequest request, HttpServletResponse response,
                                              Pagination pagination,String adv_uuid) {
        ModelAndView modelAndView = new ModelAndView("/module/appInfM/headadv/headadv_detail");
        // 菜单编码
        if(!StringUtils.isEmpty(adv_uuid)){
            Map headAdvMap = headAdvService.gettHeadAdvfById(adv_uuid);
            modelAndView.addObject("headAdvMap", headAdvMap);
        }
        return super.getDetail(request, response, modelAndView);

    }

    /**
     * 保存机构
     * @param request
     * @param response
     * @param appClientEntity
     * @return
     */
    @RequestMapping("/saveHeadAdvDetail.do")
    public ModelAndView saveHeadAdvDetail(HttpServletRequest request, HttpServletResponse response,
                                          App_Client_HeadadvEntity appClientEntity) {

        headAdvService.saveHeadAdv(request,appClientEntity, super.getLoginUser(request, response));
        /*headAdvService.saveAffix(appClientEntity,appAffixInfEntity, super.getLoginUser(request, response));*/
        Map map=super.getLoginUser(request, response);
        return new ModelAndView(new RedirectView("getHeadAdvList.do"), map);
    }
    /**
     * 删除g广告位维护
     * @param request
     * @param response
     * @param
     * @return
     */
    @RequestMapping("/deleteHeadAdvByIds.do")
    public ModelAndView deleteHeadAdvByIds(HttpServletRequest request, HttpServletResponse response, String adv_uuids) {
        headAdvService.deleteHeadAdvByIds(adv_uuids);
        Map map = super.getLoginUser(request, response);
        return new ModelAndView(new RedirectView("getHeadAdvList.do"), map);
    }
}
